package com.tiankun.eurekaticket.service.impl;

import com.tiankun.eurekaticket.mapper.TicketMapper;
import com.tiankun.eurekaticket.pojo.Ticket;
import com.tiankun.eurekaticket.service.TicketService;
import com.tiankun.eurekaticket.util.CreateRandom;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @Author liaopeng
 * @Date 2020/11/13 10:33
 * @Version 1.0
 **/
@Service("ticketService")
public class TicketServiceImpl implements TicketService {

    @Resource
    TicketMapper ticketMapper;

    @Override
    public Integer insert(Ticket ticket) {
        ticket.setRandom(CreateRandom.getRandomNickname(6));
        ticket.setState(0);
        Integer i = ticketMapper.insertSelective(ticket);
        return i;
    }

    @Override
    public Integer update(Integer id, Integer state) {
        Ticket ticket = new Ticket();
        ticket.setId(id);
        ticket.setState(state);
        int i = ticketMapper.updateByPrimaryKeySelective(ticket);
        return i;
    }

    @Override
    public Ticket find(Integer id) {
        return ticketMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Map<String, Object>> findAllticketList(Integer shopid) {
        return ticketMapper.findAllticketList(shopid);
    }

    @Override
    public List<Map<String, Object>> findAllticketListByLike(Integer shopid,String name, String random) {
        return ticketMapper.findAllticketListLike(shopid,name,random);
    }

    @Override
    public List<Map<String, Object>> userList(Integer shopid) {
        return ticketMapper.findGetTicketUserList(shopid);
    }

    @Override
    public List<Map<String, Object>> userListLike(Integer shopid,String name, Integer usestate, String random,String userName) {
        return ticketMapper.findGetTicketUserListLike(shopid,name,usestate,random,userName);
    }

    @Override
    public List<Map<String, Object>> findPutawayticketList(Integer shopid) {
        return ticketMapper.findPutawayticketList(shopid);
    }
}
